package org.tp8.sampleapp.dms.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.tp8.sampleapp.jaxb.adapter.XmlObjectIdAdapter;

/**
 * The Class AbstractModel.
 * 
 * @param <T>
 *            the generic type
 */
@XmlRootElement(name = "abstractDocModel")
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractDocModel<T> implements BaseDocModel {

	/**
	 * The Constant serialVersionUID.
	 */
	private static final long serialVersionUID = -6843727382065151899L;

	/**
	 * The id.
	 */
	@Id
	@XmlElement(name = "id")
	@XmlID
	@XmlJavaTypeAdapter(XmlObjectIdAdapter.class)
	private ObjectId id;

	/**
	 * The title.
	 */
	@XmlElement(name = "title")
	private String title;

	/**
	 * The attachment.
	 */
	@XmlElement(name = "attachment")
	private Attachment attachment;
	
	@XmlTransient
	private ObjectId attachmentId;

	public ObjectId getAttachmentId() {
		return attachmentId;
	}

	public void setAttachmentId(ObjectId attachmentId) {
		this.attachmentId = attachmentId;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.tp8.sampleapp.dms.model.BaseDocModel#getId()
	 */
	public ObjectId getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.tp8.sampleapp.dms.model.BaseDocModel#setId(org.bson.types.ObjectId)
	 */
	public void setId(ObjectId id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.tp8.sampleapp.dms.model.BaseDocModel#getTitle()
	 */
	public String getTitle() {
		return title;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.tp8.sampleapp.dms.model.BaseDocModel#setTitle(java.lang.String)
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.tp8.sampleapp.dms.model.BaseDocModel#getAttachment()
	 */
	public Attachment getAttachment() {
		return attachment;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.tp8.sampleapp.dms.model.BaseDocModel#setAttachment(org.tp8.sampleapp
	 * .dms.model.Attachment)
	 */
	public void setAttachment(Attachment attachment) {
		this.attachment = attachment;
	}

}
